home *** CD-ROM | disk | FTP | other *** search
/ Belgian Amiga Club - ADF Collection / BS1 part 26.zip / BS1 part 26 / Aztec C v5.2a disk 4.adf / 204inc_h.lzh / rexx / storage.h < prev   
C/C++ Source or Header  |  1991-03-14  |  9KB  |  235 lines

  1. #ifndef REXX_STORAGE_H
  2. #define REXX_STORAGE_H
  3. /*
  4. **    $Filename: rexx/storage.h $
  5. **    $Release: 2.04 $
  6. **    $Revision: 1.2 $
  7. **    $Date: 90/07/12 $
  8. **
  9. **    Header file to define ARexx data structures.
  10. **
  11. **    (C) Copyright 1986,1987,1988,1989,1990 William S. Hawes
  12. **        All Rights Reserved
  13. */
  14.  
  15. #ifndef EXEC_TYPES_H
  16. #include "exec/types.h"
  17. #endif
  18.  
  19. #ifndef EXEC_NODES_H
  20. #include "exec/nodes.h"
  21. #endif
  22.  
  23. #ifndef EXEC_LISTS_H
  24. #include "exec/lists.h"
  25. #endif
  26.  
  27. #ifndef EXEC_PORTS_H
  28. #include "exec/ports.h"
  29. #endif
  30.  
  31. #ifndef EXEC_LIBRARIES_H
  32. #include "exec/libraries.h"
  33. #endif
  34.  
  35. /* The NexxStr structure is used to maintain the internal strings in REXX.
  36.  * It includes the buffer area for the string and associated attributes.
  37.  * This is actually a variable-length structure; it is allocated for a
  38.  * specific length string, and the length is never modified thereafter
  39.  * (since it's used for recycling).
  40.  */
  41.  
  42. struct NexxStr {
  43.    LONG     ns_Ivalue;               /* integer value        */
  44.    UWORD    ns_Length;               /* length in bytes (excl null)    */
  45.    UBYTE    ns_Flags;               /* attribute flags        */
  46.    UBYTE    ns_Hash;               /* hash code            */
  47.    BYTE     ns_Buff[8];           /* buffer area for strings    */
  48.    };                       /* size: 16 bytes (minimum)    */
  49.  
  50. #define NXADDLEN 9               /* offset plus null byte    */
  51. #define IVALUE(nsPtr) (nsPtr->ns_Ivalue)
  52.  
  53. /* String attribute flag bit definitions                */
  54. #define NSB_KEEP     0               /* permanent string?        */
  55. #define NSB_STRING   1               /* string form valid?        */
  56. #define NSB_NOTNUM   2               /* non-numeric?            */
  57. #define NSB_NUMBER   3               /* a valid number?        */
  58. #define NSB_BINARY   4               /* integer value saved?        */
  59. #define NSB_FLOAT    5               /* floating point format?    */
  60. #define NSB_EXT      6               /* an external string?        */
  61. #define NSB_SOURCE   7               /* part of the program source?    */
  62.  
  63. /* The flag form of the string attributes                */
  64. #define NSF_KEEP     (1 << NSB_KEEP  )
  65. #define NSF_STRING   (1 << NSB_STRING)
  66. #define NSF_NOTNUM   (1 << NSB_NOTNUM)
  67. #define NSF_NUMBER   (1 << NSB_NUMBER)
  68. #define NSF_BINARY   (1 << NSB_BINARY)
  69. #define NSF_FLOAT    (1 << NSB_FLOAT )
  70. #define NSF_EXT      (1 << NSB_EXT   )
  71. #define NSF_SOURCE   (1 << NSB_SOURCE)
  72.  
  73. /* Combinations of flags                        */
  74. #define NSF_INTNUM   (NSF_NUMBER | NSF_BINARY | NSF_STRING)
  75. #define NSF_DPNUM    (NSF_NUMBER | NSF_FLOAT)
  76. #define NSF_ALPHA    (NSF_NOTNUM | NSF_STRING)
  77. #define NSF_OWNED    (NSF_SOURCE | NSF_EXT    | NSF_KEEP)
  78. #define KEEPSTR      (NSF_STRING | NSF_SOURCE | NSF_NOTNUM)
  79. #define KEEPNUM      (NSF_STRING | NSF_SOURCE | NSF_NUMBER | NSF_BINARY)
  80.  
  81. /* The RexxArg structure is identical to the NexxStr structure, but
  82.  * is allocated from system memory rather than from internal storage.
  83.  * This structure is used for passing arguments to external programs.
  84.  * It is usually passed as an "argstring", a pointer to the string buffer.
  85.  */
  86.  
  87. struct RexxArg {
  88.    LONG     ra_Size;               /* total allocated length    */
  89.    UWORD    ra_Length;               /* length of string        */
  90.    UBYTE    ra_Flags;               /* attribute flags        */
  91.    UBYTE    ra_Hash;               /* hash code            */
  92.    BYTE     ra_Buff[8];           /* buffer area            */
  93.    };                       /* size: 16 bytes (minimum)    */
  94.  
  95. /* The RexxMsg structure is used for all communications with REXX
  96.  * programs.  It is an EXEC message with a parameter block appended.
  97.  */
  98.  
  99. struct RexxMsg {
  100.    struct Message rm_Node;           /* EXEC message structure    */
  101.    APTR     rm_TaskBlock;           /* global structure (private)    */
  102.    APTR     rm_LibBase;           /* library base (private)    */
  103.    LONG     rm_Action;               /* command (action) code    */
  104.    LONG     rm_Result1;           /* primary result (return code)    */
  105.    LONG     rm_Result2;           /* secondary result        */
  106.    STRPTR   rm_Args[16];           /* argument block (ARG0-ARG15)    */
  107.  
  108.    struct MsgPort *rm_PassPort;        /* forwarding port        */
  109.    STRPTR   rm_CommAddr;           /* host address (port name)    */
  110.    STRPTR   rm_FileExt;           /* file extension        */
  111.    LONG     rm_Stdin;               /* input stream (filehandle)    */
  112.    LONG     rm_Stdout;               /* output stream (filehandle)    */
  113.    LONG     rm_avail;               /* future expansion        */
  114.    };                       /* size: 128 bytes        */
  115.  
  116. /* Field definitions                            */
  117. #define ARG0(rmp) (rmp->rm_Args[0])    /* start of argblock        */
  118. #define ARG1(rmp) (rmp->rm_Args[1])    /* first argument        */
  119. #define ARG2(rmp) (rmp->rm_Args[2])    /* second argument        */
  120.  
  121. #define MAXRMARG  15               /* maximum arguments        */
  122.  
  123. /* Command (action) codes for message packets                */
  124. #define RXCOMM      0x01000000           /* a command-level invocation    */
  125. #define RXFUNC      0x02000000           /* a function call        */
  126. #define RXCLOSE   0x03000000           /* close the REXX server    */
  127. #define RXQUERY   0x04000000           /* query for information    */
  128. #define RXADDFH   0x07000000           /* add a function host        */
  129. #define RXADDLIB  0x08000000           /* add a function library    */
  130. #define RXREMLIB  0x09000000           /* remove a function library    */
  131. #define RXADDCON  0x0A000000           /* add/update a ClipList string    */
  132. #define RXREMCON  0x0B000000           /* remove a ClipList string    */
  133. #define RXTCOPN   0x0C000000           /* open the trace console    */
  134. #define RXTCCLS   0x0D000000           /* close the trace console    */
  135.  
  136. /* Command modifier flag bits                        */
  137. #define RXFB_NOIO    16           /* suppress I/O inheritance?    */
  138. #define RXFB_RESULT  17           /* result string expected?    */
  139. #define RXFB_STRING  18           /* program is a "string file"?    */
  140. #define RXFB_TOKEN   19           /* tokenize the command line?    */
  141. #define RXFB_NONRET  20           /* a "no-return" message?    */
  142.  
  143. /* The flag form of the command modifiers                */
  144. #define RXFF_NOIO    (1L << RXFB_NOIO  )
  145. #define RXFF_RESULT  (1L << RXFB_RESULT)
  146. #define RXFF_STRING  (1L << RXFB_STRING)
  147. #define RXFF_TOKEN   (1L << RXFB_TOKEN )
  148. #define RXFF_NONRET  (1L << RXFB_NONRET)
  149.  
  150. #define RXCODEMASK   0xFF000000
  151. #define RXARGMASK    0x0000000F
  152.  
  153. /* The RexxRsrc structure is used to manage global resources.  Each node
  154.  * has a name string created as a RexxArg structure, and the total size
  155.  * of the node is saved in the "rr_Size" field.  The REXX systems library
  156.  * provides functions to allocate and release resource nodes.  If special
  157.  * deletion operations are required, an offset and base can be provided in
  158.  * "rr_Func" and "rr_Base", respectively.  This "autodelete" function will
  159.  * be called with the base in register A6 and the node in A0.
  160.  */
  161.  
  162. struct RexxRsrc {
  163.    struct Node rr_Node;
  164.    WORD     rr_Func;               /* "auto-delete" offset        */
  165.    APTR     rr_Base;               /* "auto-delete" base        */
  166.    LONG     rr_Size;               /* total size of node        */
  167.    LONG     rr_Arg1;               /* available ...        */
  168.    LONG     rr_Arg2;               /* available ...        */
  169.    };                       /* size: 32 bytes        */
  170.  
  171. /* Resource node types                            */
  172. #define RRT_ANY      0               /* any node type ...        */
  173. #define RRT_LIB      1               /* a function library        */
  174. #define RRT_PORT     2               /* a public port        */
  175. #define RRT_FILE     3               /* a file IoBuff        */
  176. #define RRT_HOST     4               /* a function host        */
  177. #define RRT_CLIP     5               /* a Clip List node        */
  178.  
  179. /* The RexxTask structure holds the fields used by REXX to communicate with
  180.  * external processes, including the client task.  It includes the global
  181.  * data structure (and the base environment).  The structure is passed to
  182.  * the newly-created task in its "wake-up" message.
  183.  */
  184.  
  185. #define GLOBALSZ  200               /* total size of GlobalData    */
  186.  
  187. struct RexxTask {
  188.    BYTE     rt_Global[GLOBALSZ];       /* global data structure    */
  189.    struct MsgPort rt_MsgPort;           /* global message port        */
  190.    UBYTE    rt_Flags;               /* task flag bits        */
  191.    BYTE     rt_SigBit;               /* signal bit            */
  192.  
  193.    APTR     rt_ClientID;           /* the client's task ID        */
  194.    APTR     rt_MsgPkt;               /* the packet being processed    */
  195.    APTR     rt_TaskID;               /* our task ID            */
  196.    APTR     rt_RexxPort;           /* the REXX public port        */
  197.  
  198.    APTR     rt_ErrTrap;           /* Error trap address        */
  199.    APTR     rt_StackPtr;           /* stack pointer for traps    */
  200.  
  201.    struct List rt_Header1;           /* Environment list        */
  202.    struct List rt_Header2;           /* Memory freelist        */
  203.    struct List rt_Header3;           /* Memory allocation list    */
  204.    struct List rt_Header4;           /* Files list            */
  205.    struct List rt_Header5;           /* Message Ports List        */
  206.    };
  207.  
  208. /* Definitions for RexxTask flag bits                    */
  209. #define RTFB_TRACE   0               /* external trace flag        */
  210. #define RTFB_HALT    1               /* external halt flag        */
  211. #define RTFB_SUSP    2               /* suspend task?        */
  212. #define RTFB_TCUSE   3               /* trace console in use?    */
  213. #define RTFB_WAIT    6               /* waiting for reply?        */
  214. #define RTFB_CLOSE   7               /* task completed?        */
  215.  
  216. /* Definitions for memory allocation constants                */
  217. #define MEMQUANT  16L               /* quantum of memory space    */
  218. #define MEMMASK   0xFFFFFFF0           /* mask for rounding the size    */
  219.  
  220. #define MEMQUICK  (1L << 0 )           /* EXEC flags: MEMF_PUBLIC    */
  221. #define MEMCLEAR  (1L << 16)           /* EXEC flags: MEMF_CLEAR    */
  222.  
  223. /* The SrcNode is a temporary structure used to hold values destined for
  224.  * a segment array.  It is also used to maintain the memory freelist.
  225.  */
  226.  
  227. struct SrcNode {
  228.    struct SrcNode *sn_Succ;           /* next node            */
  229.    struct SrcNode *sn_Pred;           /* previous node        */
  230.    APTR     sn_Ptr;               /* pointer value        */
  231.    LONG     sn_Size;               /* size of object        */
  232.    };                       /* size: 16 bytes        */
  233.  
  234. #endif
  235.